package provagrails

class CourseController {
    static scaffold =  true
    def index={
        def courses=Course.findAll()
        return [courses:courses]
    }

    def shownewargumentform={
        def course=params.id;
        println("id corso:"+course)
        return [course:course];
    }
    def newargument={

        def name=request.getParameter('argumentname');
        def course=params.idcorso;

        def seriouscourse = Course.get(course);

        new Argument(name: name , course: seriouscourse).save(failOnError: true)


        redirect(action:"index")
    }
}
